/*
 * @Description:
 * @Version: 2.0
 * @Autor: snzo.chen
 * @Date: 2023-11-27 15:12:12
 * @LastEditors: snzo.chen
 * @LastEditTime: 2023-12-20 10:36:19
 */
import { ContentTypeEnum } from '@/enums/httpEnum';
import { request, Response } from '@/utils/request';

/**
 * 上传图片
 * @param data
 * @returns
 */
export function uploadImg(file) {
  const formData = new FormData();
  formData.append('file', file);
  return request<Response>(
    {
      url: '/upload/uploadImg',
      method: 'post',
      data: formData,
      headers: { 'Content-Type': ContentTypeEnum.FORM_DATA },
    },
    {
      isGetDataDirectly: false,
    },
  );
}

/**
 * 上传其他文件
 * @param data
 * @returns
 */
export function uploadOther(file) {
  const formData = new FormData();
  formData.append('file', file);
  return request<Response>(
    {
      url: '/upload/uploadOther',
      method: 'post',
      data: formData,
      headers: { 'Content-Type': ContentTypeEnum.FORM_DATA },
    },
    {
      isGetDataDirectly: false,
    },
  );
}

/**
 * 上传视频
 * @param data
 * @returns
 */
export function uploadVideo(file) {
  const formData = new FormData();
  formData.append('file', file);
  return request<Response>(
    {
      url: '/upload/uploadVideo',
      method: 'post',
      data: formData,
      headers: { 'Content-Type': ContentTypeEnum.FORM_DATA },
    },
    {
      isGetDataDirectly: false,
    },
  );
}
